<?php 
$attributes = array('id' => 'add_form_bl');
echo form_open('bline/savebusinessline', $attributes); ?>
<table width="100%">
    <tr>
        <td class="menuActual">Config > Data > Add Business Line</td>
    </tr>
    <tr>
        <td>
            <span id='bline_form_msg' class="msg_error">* Required fields</span>
            <table>
            <?php
            if(!isset($business_line)) $business_line = new Business_line_dto();
            echo form_hidden('idBL', $business_line->id);
            ?>
                <tr>
                    <td class="descripcionForm"><?php echo form_label("Name: *");?></td>
                    <td class="descripcionForm">
                        <?php
                        $attributes = array('id' => 'nameBL', 'rows' => '3', 'cols' => '50','name' => 'nameBL', 'maxlength' => '250', 
                        'value' => (set_value('nameBL') == '' ? $business_line->name : set_value('nameBL')));
                        echo form_textarea($attributes);
                        ?>
                    </td>
                </tr>
                <tr>
                    <td class="descripcionForm"><?php echo form_label("Round: *"); ?></td>
                    <td class="descripcionForm">
                        <?php
                        $opcionesRound = array();
                        if(isset($rounds)){
                            $defaultSelection = $business_line->idRound;
                            foreach ($rounds as $rnd) {
                                $nombreRound_cortado = strlen($rnd->name) > 50 ? substr($rnd->name, 0, 50) . ' (...)' : $rnd->name;
                                $opcionesRound[$rnd->id] = $nombreRound_cortado;
                                if($defaultSelection == 0) $defaultSelection = $rnd->id;
                            }
                        
                            echo form_dropdown('idRoundBL', $opcionesRound, $defaultSelection, 'id = idRoundBL');
                        }
                        ?>
                    </td>
              </tr>                
                <tr>
                    <td class="descripcionForm" colspan="2"><?php echo validation_errors(); ?></td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<?php echo form_close();?>